﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Location.cs" company="DissingNellemann">
//   
// All rights reserved </copyright>
// <summary>
//   The location.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Website.Models.Domain
{
    using System;
    using System.ComponentModel.DataAnnotations;

    using Website.Models.Base;

    /// <summary>
    ///     The location.
    /// </summary>
    public class Location : Entity
    {
        #region Public Properties

        /// <summary>
        ///     Gets or sets the address.
        /// </summary>
        public Address Address { get; set; }

        /// <summary>
        ///     Gets or sets the name.
        /// </summary>
        [Required(ErrorMessage = "Du skal angive et navn.")]
        public string Name { get; set; }

        /// <summary>
        ///     Gets or sets the region.
        /// </summary>
        public Region Region { get; set; }

        /// <summary>
        ///     Gets or sets the region id.
        /// </summary>
        [Required(ErrorMessage = "Du skal angive en region.")]
        public Guid RegionID { get; set; }

        /// <summary>
        ///     Gets or sets a value indicating whether within 150 km.
        /// </summary>
        public bool Within150Km { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="dto">
        /// The dto.
        /// </param>
        /// <returns>
        /// The <see cref="Location"/>.
        /// </returns>
        public static Location Convert(CRUDServices.Location dto)
        {
            return new Location
                       {
                           ID = dto.ID, 
                           Name = dto.Name, 
                           Within150Km = dto.Within150Km, 
                           Address = Address.Convert(dto.Address), 
                           Region = Region.Convert(dto.Region)
                       };
        }

        #endregion
    }
}